/*
 * @Author: Troubadour 2276791354@qq.com
 * @Date: 2024-08-14 22:45:49
 * @LastEditors: Troubadour 2276791354@qq.com
 * @LastEditTime: 2024-08-18 12:02:21
 * @Version:
 * @Description:
 */

#ifndef __TFT_DRV_H__
#define __TFT_DRV_H__

/*-------------------------------------------------------------------------------------------------------------------------------------
-                                                  Include file                                                                       -
--------------------------------------------------------------------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdint.h>

/*-------------------------------------------------------------------------------------------------------------------------------------
-                                                  External macro                                                                     -
--------------------------------------------------------------------------------------------------------------------------------------*/

#define TFT_DRV_STATE_OK    (0)
#define TFT_DRV_STATE_ERR   (-1)

#define ST7735_XSTART 0
#define ST7735_YSTART 0
#define ST7735_WIDTH  128
#define ST7735_HEIGHT 160
// Screen Direction
#define ST7735_ROTATION 0
// Color Mode: RGB or BGR
#define ST7735_MADCTL_RGB 0x00
#define ST7735_MADCTL_BGR 0x08
#define ST7735_MADCTL_MODE ST7735_MADCTL_RGB
// Color Inverse: 0=NO, 1=YES
#define ST7735_INVERSE 0
// Color definitions
#define ST7735_BLACK                0x0000
#define ST7735_BLUE                 0x001F
#define ST7735_RED                  0xF800
#define ST7735_GREEN                0x07E0
#define ST7735_CYAN                 0x07FF
#define ST7735_MAGENTA              0xF81F
#define ST7735_YELLOW               0xFFE0
#define ST7735_WHITE                0xFFFF
#define ST7735_COLOR565(r, g, b)    (((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3))
/*-------------------------------------------------------------------------------------------------------------------------------------
-                                                  External enum                                                                      -
--------------------------------------------------------------------------------------------------------------------------------------*/


/*-------------------------------------------------------------------------------------------------------------------------------------
-                                                  External structure                                                                 -
--------------------------------------------------------------------------------------------------------------------------------------*/


/*-------------------------------------------------------------------------------------------------------------------------------------
-                                                  External variables                                                                 -
--------------------------------------------------------------------------------------------------------------------------------------*/


/*-------------------------------------------------------------------------------------------------------------------------------------
-                                                  External function                                                                  -
--------------------------------------------------------------------------------------------------------------------------------------*/

int TFT_Init(void);
void TFT_BackLight(uint8_t state);
void TFT_SetRotation(uint8_t rotation);
void TFT_DrawPoint(uint8_t x, uint8_t y, uint16_t Data);
void ST7735_DrawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color);
void ST7735_DrawRectangleLVGL(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint16_t *color);
void TFT_Clear(uint16_t Color);

#endif  /* __TFT_DRV_H__ */
